package com.kunbo.cn.app.controller;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.kunbo.cn.app.service.SaleCustomerOrderService;
import com.kunbo.cn.util.retu.BuildBean;
import com.kunbo.cn.util.retu.ResultBean;
/**
 *客户订单管理App
 * @author bjl  
 * @date 2019年3月26日 
 */
@RestController
@RequestMapping("/CustomerOrder")
public class SaleCustomerOrderController {
	@Autowired
	private SaleCustomerOrderService service;
	/**
	 * 获取客户名称
	 * @param login_nameke客户登录账号
	 * @return
	 */
	@GetMapping("/getTitle")
	public String getTitle(
			@RequestParam("login_name")String login_name,
			@RequestParam("table")String table
			){
		return service.getTitle(login_name,table);
	}
	/**
	 * 销售订单号下拉（获取该客户的所有订单）
	 * @param login_nameke客户登录账号
	 * @return
	 */
	@PostMapping("/Order")
	public ResultBean<List<Map<String,Object>>> getSaleOrder(
			@RequestParam("login_name")String login_name
			){
		ResultBean<List<Map<String,Object>>> result  = new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "succes", "error",service.getSaleOrder(login_name));
	}
	/**
	 * 获取物料
	 * @return
	 */
	@PostMapping("/matter")
	public ResultBean<List<Map<String,Object>>> CarrierUty(
			@RequestParam("type")String type
			){
		ResultBean<List<Map<String,Object>>> result = new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "succes", "error",service.matter(type));
	}
	/**
	 * 销售订单列表(获取该客户的所有订单）
	 * @param login_nameke客户登录账号
	 * @return
	 */
	@GetMapping("/getCustomerOrder")
	public ResultBean<List<Map<String,Object>>> getCustomerOrder(
			@RequestParam("login_name")String login_name,
			@RequestParam("materials")String materials,
			@RequestParam("sale_order_code")String sale_order_code,
			@RequestParam("start_time")String start_time,
			@RequestParam("end_time")String end_time,
			@RequestParam("page")Integer page,
			@RequestParam("pageSize")Integer pageSize
			){
		System.out.println("{****************start_time*********************}"+start_time);
		System.out.println("{****************end_time*********************}"+end_time);

		ResultBean<List<Map<String,Object>>> result  = new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "success", "error", service.getCustomerOrder(login_name,materials,sale_order_code,start_time,end_time,page,pageSize));
	}
	/**
	 * 客户app订单详情
	 * 
	 */
	@GetMapping("/Orderdetails")
	public ResultBean<List<Map<String,Object>>> Orderdetails(
			@RequestParam("id")Integer id
			){
		ResultBean<List<Map<String,Object>>>  result =  new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "success", "error", service.Orderdetails(id));
	}
	
	/**
	 * 客户app通知单列表
	 * 
	 */
	@PostMapping("/noticeList")
	public ResultBean<List<Map<String,Object>>>noticeList(
			@RequestParam("login_name")String login_name,
			@RequestParam("page")Integer page,
			@RequestParam("pageSize")Integer pageSize
			){
		ResultBean<List<Map<String,Object>>>  result =  new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "success", "error", service.noticeList(login_name ,page,pageSize));
	}
	/**
	 * 客户app通知单详情
	 * 
	 */
	@PostMapping("/noticedetails")
	public ResultBean<List<Map<String,Object>>> noticedetails(
			@RequestParam("id")Integer id
			){
		ResultBean<List<Map<String,Object>>>  result =  new ResultBean<List<Map<String,Object>>>();
		return BuildBean.buildResult(result, "success", "error", service.noticedetails(id));
	}
}
